import { MetadataRoute } from "next";

export default async function sitemap(): Promise<MetadataRoute.Sitemap> {

  const res = await fetch("http://i18nport.dongsongkeji.com.cn/index?lang=zh")
  const { data }: {data: any } = await res.json()
  const all: MetadataRoute.Sitemap = [...data.inductance,
     ...data.photoelectric, 
     ...data.measurement, 
     ...data.capacitance].map(item => ({
    url: `http://dongsongkeji.com.cn/${item.Language}/product-detail/${item.Language}/${item.Type}/${item.Serices}/${item.Name}/${item.id}`,
  })
  )
  return [
    {
      url: "http://dongsongkeji.com.cn/",
      lastModified: new Date()
    },
    ...all
  ]
}